#include <iostream>
#include <math.h>
#include <stdio.h>
#define MAXQSIZE 100
using namespace std;

struct BiNode {
  int data;
  BiNode *lchild, *rchild;
};

struct SqQueue {
  BiNode *base[100];
  int front, rear;
};

void CreateBiTree(BiNode *&T) {

  char ch;
  cin >> ch;
  if (ch == '#')
    T = NULL;
  else {
    T = new BiNode;
    T->data = ch;
    CreateBiTree(T->lchild);
    CreateBiTree(T->rchild);
  }
}

#include <queue>
void LevelOrder(BiNode *&Tree) {
  queue<BiNode *> q;
  if (Tree != NULL) {
    q.push(Tree); //根节点进队列
  }

  while (q.empty() == false) //队列不为空判断
  {
    cout << char(q.front()->data);

    if (q.front()->lchild != NULL) //如果有左孩子，leftChild入队列
    {
      q.push(q.front()->lchild);
    }

    if (q.front()->rchild != NULL) //如果有右孩子，rightChild入队列
    {
      q.push(q.front()->rchild);
    }
    q.pop(); //已经遍历过的节点出队列
  }
}

int main() {

  BiNode *Tree;
  CreateBiTree(Tree);
  LevelOrder(Tree);
  return 0;
}
